package com.eos.control.action.customer;

import com.eos.business.service.SysProductBusinessService;
import com.eos.common.tool.ConstantTool;
import com.eos.common.tool.ObjectUtils;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SysProduct;
import com.eos.orm.mybatis.model.SysUser;

public class DeleteProductTypeAction extends AbstractBaseAction {
	private static final long serialVersionUID = 8260313667367803659L;
	private Integer productId;

	public void setProductId(Integer productId) {
		this.productId = productId;
	}

	@Override
	public String execute() {
		try { 
			if(null == productId || productId.intValue() <=0){
				statusCode = "300";
				message = "参数错误, 删除品名信息失败!";
			}else{
				SysProductBusinessService spbs = new SysProductBusinessService();
				SysUser user = (SysUser)getSession().getAttribute("SysUser");
				int userId = user.getId();
				String strTime = ObjectUtils.formatDate(null, "yyyy-MM-dd HH:mm:ss");
				SysProduct product = new SysProduct();
				product.setId(productId);
				product.setDealFlag(ConstantTool.DEAL_FLAG_FAIL);
				product.setUpdateUserId(userId+"");
				product.setModifyTime(strTime);
				String exeStatus = spbs.updateSysProductPKSelective(product);
				if("SUCCESS".equals(exeStatus)){
					statusCode = "200";
					message = "删除品名信息成功!";
				}else{
					statusCode = "300";
					message = "系统繁忙, 删除品名信息失败!";
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			statusCode = "300";
			message = "系统异常, 删除品名信息失败!";
		}
		return SUCCESS;
	}
}
